Extract early config validation from runServeCmd into testable helpers#45583
Extract early config validation from runServeCmd into testable helpers#45583raju249 wants to merge 1 commit into
Conversation
Move five pure config validations (OTEL logs/tracing dependency, osquery host identifier, server URL prefix normalization, private key flag exclusivity, private key length) into helper functions in cmd/fleet/serve_validation.go and add unit tests for each. Behavior is unchanged; runServeCmd still fatals at the same points via the same initFatal descriptions. Part of fleetdm#33370.
|
No actionable comments were generated in the recent review. 🎉 ℹ️ Recent review info⚙️ Run configurationConfiguration used: Path: .coderabbit.yaml Review profile: CHILL Plan: Pro Run ID: 📒 Files selected for processing (3)
WalkthroughThis PR consolidates server startup configuration validation by extracting inline validation logic from 🚥 Pre-merge checks | ✅ 4 | ❌ 1❌ Failed checks (1 warning)
✅ Passed checks (4 passed)
✏️ Tip: You can configure your own custom pre-merge checks in the settings. ✨ Finishing Touches🧪 Generate unit tests (beta)
Tip 💬 Introducing Slack Agent: The best way for teams to turn conversations into code.Slack Agent is built on CodeRabbit's deep understanding of your code, so your team can collaborate across the entire SDLC without losing context.
Built for teams:
One agent for your entire SDLC. Right inside Slack. Thanks for using CodeRabbit! It's free for OSS, and your support helps us grow. If you like it, consider giving us a shout-out. Comment |
|
@getvictor - I did some more refactoring of serve.go file. Can you please take a review? Thanks! 🙏 🙇 |
Codecov Report❌ Patch coverage is
Additional details and impacted files@@ Coverage Diff @@
## main #45583 +/- ##
==========================================
- Coverage 66.74% 66.73% -0.01%
==========================================
Files 2740 2741 +1
Lines 219163 219178 +15
Branches 10947 10947
==========================================
- Hits 146283 146277 -6
- Misses 59649 59677 +28
+ Partials 13231 13224 -7
Flags with carried forward coverage won't be shown. Click here to find out more. ☔ View full report in Codecov by Sentry. 🚀 New features to boost your workflow:
|
Extracts five pure config validations from
runServeCmdinto helpers in a newcmd/fleet/serve_validation.go, and adds table-driven unit tests for each:validateOTELLoggingConfig— OTEL logs requires tracing enabledvalidateOsqueryHostIdentifier— must be one ofprovided,instance,uuid,hostnamenormalizeAndValidateServerURLPrefix— trims/normalizes leading-slash, validates againstallowedURLPrefixRegexpvalidateServerPrivateKeyExclusive—private_keyandprivate_key_arnare mutually exclusivevalidateServerPrivateKeyLength— minimum 32 bytes when setBehavior is byte-identical: error messages preserved,
runServeCmdstill callsinitFatalwith the same descriptions at the same points.serve.goshrinks by 21 lines.Broader plan
Issue #33370 calls for moving logic out of
serve.go("should only contain critical config and dependency injection logic"). This PR is one slice. Realistic follow-ups, each in their own small PR:initFatalinjection from Inject initFatal as a package-level var (#33370) #45343 to cover runtime failure paths (datastore init, Redis init, MDM init, etc.)Related issue: Refs #33370
Checklist for submitter
Summary by CodeRabbit
Refactor
Tests